#include <iostream>
#include <stack>
#include <unordered_map>
using namespace std;

bool a(string s) {
    stack<char> st;
    unordered_map<char, char> umap = {{')', '('}, {']', '['}, {'}', '{'}, {'>', '<'}};
    
    for (int i = 0; i < s.length(); i++) {
        if (umap.count(s[i]) == 0) {
            st.push(s[i]);
        } else {
            if (st.empty() || umap[s[i]] != st.top()) {
                return false;
            }
            st.pop();
        }
    }
    
    return st.empty();
}

int main() {
    string s;
    cin >> s;
    
    cout << (a(s) ? "true" : "false") << endl;
    
    return 0;
}